FROM golang:1.15.0-alpine3.12 as builder
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/main/" > /etc/apk/repositories
#USER root
RUN apk update && apk add --no-cache  ca-certificates tzdata
#RUN adduser -D -g '' appuser
# 配置代理
ENV GOPROXY https://goproxy.cn

#ENV TZ=Asia/Shanghai
#RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ADD . /

WORKDIR /
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -o /go-proxy


FROM alpine:latest
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
#COPY --from=builder /etc/passwd /etc/passwd

COPY --from=builder /go-proxy /go-proxy
#USER root
#EXPOSE 80
CMD ["/go-proxy"]
